<div class="wrap">
	<ul class="order_list">
		<li>
			<label>设备编号</label>
			<select id="equipmentNum"></select>
		</li>
		<li>
			<label>设备名称</label>
			<input id="equipmentName" readonly="readonly"/>
		</li>
		<li>
			<label>当前负责人</label>
			<input id="equipmentUser" readonly="readonly"/>
		</li>
		<li>
			<label>故障现象</label>
			<input type="text" id="userLoca">
		</li>
		<li>
			<a href="javascript:void(0)" id="orderSubmit">提交</a>
		</li>
	</ul>	
</div>
<script>
	//设备编号
	$.ajax({
		type:"post",
		url:"http://39.108.164.20/device/SysUser/SelDevice",
		dataType:"json",
		success:function(res){
			$("#equipmentNum").empty();
			var data = res.result.data;
			var html;
			for(let i=0;i<data.length;i++){
				html += '<option>'+data[i].sb_id+'</option>';
			}
			$("#equipmentNum").append(html);
			$("#equipmentName").val(data[0].sb_name);
			$("#equipmentUser").val(data[0].pet_name);
		}
	});
	//选择设备编号下拉框
	$("#equipmentNum").on("change",function(){
		var sbId = $(this).val();
		$.ajax({
			type:"post",
			url:"http://39.108.164.20/device/SysUser/SelDevice",
			dataType:"json",
			success:function(res){
				var data = res.result.data;
				for(let i=0;i<data.length;i++){
					if(sbId == data[i].sb_id){
						$("#equipmentName").val(data[i].sb_name);
						$("#equipmentUser").val(data[i].pet_name);
					}
				}
			}
		});
	})
	//提交信息
	$("#orderSubmit").on("click",function(){
		var sb_id = $("#equipmentNum option:selected").val(),
			gz_details = $("#userLoca").val();
		if($("#userLoca").val()!= ""){
			$.ajax({
				type:"post",
				url:"http://39.108.164.20/device/SysUser/InsDevRepair",
				data:{
					sb_id:sb_id,
					gz_details:gz_details
				},
				dataType:"json",
				success:function(res){
					alert(res.result.msg)
				}
			});
		}else{
			alert("请填写设备故障信息！")
		}
	})
</script>